/*    */ package com.zimbra.cs.dav.property;
/*    */ 
/*    */ import com.zimbra.common.util.Log;
/*    */ import com.zimbra.common.util.ZimbraLog;
/*    */ import com.zimbra.cs.dav.DavContext;
/*    */ import com.zimbra.cs.dav.DavElements.CardDav;
/*    */ import com.zimbra.cs.dav.resource.AddressObject;
/*    */ import java.util.ArrayList;
/*    */ import org.dom4j.Element;
/*    */ import org.dom4j.QName;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class CardDavProperty
/*    */   extends ResourceProperty
/*    */ {
/*    */   public static ResourceProperty getAddressbookHomeSet(String user)
/*    */   {
/* 33 */     return new AddressbookHomeSet(user);
/*    */   }
/*    */   
/*    */   public static ResourceProperty getAddressbookData(Element prop, AddressObject contact) {
/* 37 */     return new AddressbookData(prop, contact);
/*    */   }
/*    */   
/*    */   protected CardDavProperty(QName name) {
/* 41 */     super(name);
/* 42 */     setProtected(true);
/* 43 */     setVisible(true);
/*    */   }
/*    */   
/*    */   private static class AddressbookHomeSet extends CardDavProperty {
/*    */     public AddressbookHomeSet(String user) {
/* 48 */       super();
/* 49 */       this.mChildren.add(createHref("/dav/" + user + "/"));
/*    */     }
/*    */   }
/*    */   
/*    */   private static class AddressbookData extends CardDavProperty {
/*    */     ArrayList<String> props;
/*    */     AddressObject contact;
/*    */     
/* 57 */     public AddressbookData(Element prop, AddressObject c) { super();
/* 58 */       this.props = new ArrayList();
/* 59 */       for (Object child : prop.elements()) {
/* 60 */         if ((child instanceof Element)) {
/* 61 */           Element e = (Element)child;
/* 62 */           if (e.getQName().equals(DavElements.CardDav.E_PROP))
/* 63 */             this.props.add(e.attributeValue("name"));
/*    */         }
/*    */       }
/* 66 */       this.contact = c;
/*    */     }
/*    */     
/* 69 */     public Element toElement(DavContext ctxt, Element parent, boolean nameOnly) { Element abd = super.toElement(ctxt, parent, nameOnly);
/*    */       try {
/* 71 */         abd.setText(this.contact.toVCard(ctxt, this.props));
/*    */       } catch (Exception e) {
/* 73 */         ZimbraLog.dav.warn("can't get vcard content", e);
/*    */       }
/* 75 */       return abd;
/*    */     }
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/dav/property/CardDavProperty.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */